package com.gz.thread.juc.cas;

import java.util.concurrent.atomic.AtomicInteger;

public class CAS {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger();
        atomicInteger.set(10);
        //  int expect  ->  期望的值  , int update  ->更新的值
        atomicInteger.compareAndSet(20,30);

        System.out.println(atomicInteger.get());

        atomicInteger.compareAndSet(10,30);

        System.out.println(atomicInteger.get());
    }
}
